package com.cxz.food.service.impl;

import com.cxz.food.dao.FoodCartMapper;
import com.cxz.food.domain.FoodCart;
import com.cxz.food.domain.vo.FoodPlaceResVo;
import com.cxz.food.service.FoodCartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class FoodCartServiceImpl implements FoodCartService {


    @Autowired
    private FoodCartMapper foodCartMapper;


    @Override
    public void insertFoodCart(FoodCart foodCart) {

        foodCartMapper.insertFoodCart(foodCart);
    }

    @Override
    public void deleteFoodCart(FoodCart foodCart) {

        foodCartMapper.deleteFoodCart(foodCart);
    }


    @Override
    public void deleteFoodCartByCartCode(String cartCode) {
        foodCartMapper.deleteFoodCartByCartCode(cartCode);
    }

    @Override
    public List<FoodPlaceResVo> getFoodsByCartCode(String cartCode) throws Exception {

        List<FoodPlaceResVo> foods = foodCartMapper.getFoodsByCartCode(cartCode);

        if(foods!=null){
            return foods;
        }else {
            throw new Exception();
        }


    }
}
